<template>
    <div class="app-container">

        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item label="客户" prop="custom">
                <el-input v-model="queryParams.custom" @input="onInputChange1($event)" placeholder="请输入客户" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="机型" prop="model">
                <el-input v-model="queryParams.model" @input="onInputChange2($event)" placeholder="请输入机型" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="项目编码" prop="projectNo">
                <el-input v-model="queryParams.projectNo" @input="onInputChange8($event)" placeholder="请输入项目编码"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item label="芯片组" prop="chipGroup">
                <el-input v-model="queryParams.chipGroup" @input="onInputChange3($event)" placeholder="请输入芯片组" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="AD板" prop="adBoard">
                <el-input v-model="queryParams.adBoard" @input="onInputChange4($event)" placeholder="请输入芯片组" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="LCM/OC" prop="lcmOc">
                <el-input v-model.trim="queryParams.lcmOc" @input="onInputChange5($event)" placeholder="请输入芯片组"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="电源/适配器" class="labelword" prop="powerSupply">
                <el-input v-model.trim="queryParams.powerSupply" @input="onInputChange0($event)" placeholder="请输入电源/适配器"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <!-- <el-form-item label="ARM板" prop="armBoard">
                <el-input v-model.trim="queryParams.armBoard" @input="onInputChange6($event)" placeholder="请输入ARM板"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="恒流板" prop="currentBoard">
                <el-input v-model.trim="queryParams.currentBoard" @input="onInputChange7($event)" placeholder="请输入恒流板"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="其他" prop="other">
                <el-input v-model.trim="queryParams.other" @input="onInputChange9($event)" placeholder="请输入其他" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item> -->
            <el-form-item label="bug编码" prop="bugCode">
                <el-input v-model="queryParams.bugCode" @input="inputOnchange1($event)" placeholder="请输入bugCode"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <!-- <el-form-item label="bug识别" prop="identify">
                <el-input v-model="queryParams.identify" @input="inputOnchange2($event)" placeholder="请输入bug识别标识"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="严重程度" prop="level">
                <el-input v-model="queryParams.level" @input="inputOnchange3($event)" placeholder="请输入严重程度" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="设备型号" prop="modelCode">
                <el-input v-model="queryParams.modelCode" @input="inputOnchange4($event)" placeholder="请输入设备型号"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="不良率" prop="badPersentage">
                <el-input v-model="queryParams.badPersentage" @input="inputOnchange5($event)" placeholder="请输入不良率"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item> -->
            <el-form-item label="bug状态">
                <el-select @change="selectChange($event)" v-model="queryParams.bugStatus" placeholder="请选择bug状态"
                    clearable>
                    <el-option v-for="dict in dict.type.bugs_status" :key="dict.value" :label="dict.label"
                        :value="dict.value" />
                </el-select>
            </el-form-item>

            <el-form-item label="电源/适配器标识" class="labelword" prop="powerSuppleId">
                <el-input v-model="queryParams.powerSuppleId" @input="inputOnchange6($event)" placeholder="请输入电源/适配器标识"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="lcm/oc标识" class="labelword" prop="lcmOcId">
                <el-input v-model="queryParams.lcmOcId" @input="inputOnchange7($event)" placeholder="请输入lcm/oc标识"
                    clearable @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item label="责任人" prop="respon">
                <el-input v-model="queryParams.respon" @input="inputOnchange8($event)" placeholder="请输入bug责任人" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="创建人" prop="bugCreateUser">
                <el-input v-model="queryParams.bugCreateUser" @input="inputOnchange9($event)" placeholder="请输入bug创建人" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        <el-tooltip content="导出全部bug库" placement="bottom" effect="light">
            <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                v-hasPermi="['business:bugs:export']">导出bug库</el-button>
        </el-tooltip>
        <el-tooltip content="导出第一版本的描述，最后关闭版本的分析与对策" placement="bottom" effect="light">
            <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExportTwo"
                v-hasPermi="['business:bugs:export']">导出</el-button>
        </el-tooltip>
        <el-table border v-loading="loading" :data="projectBugList" :row-class-name="tableRowClassName">
            <!-- <el-table-column type="selection" width="55" align="center" @selection-change="handleSelectionChange" /> -->
            <el-table-column label="客户" align="center" prop="custom"></el-table-column>
            <el-table-column label="项目编码" align="left" width="120px" prop="projectNo" />
            <el-table-column label="专案类别" align="center" prop="plevel" />
            <el-table-column label="机型" align="center" prop="model" />
            <el-table-column label="AD板" align="center" prop="adBoard" />
            <el-table-column label="芯片组" align="center" prop="chipGroup" />
            <el-table-column label="LCM/OC" align="center" prop="lcmOc" />
            <el-table-column label="电源/适配器" align="center" prop="powerSupply" />
            <el-table-column label="Arm板" align="center" prop="armBoard" />
            <el-table-column label="bug编码" width="125" align="center" prop="bugCode" />
            <el-table-column label="识别" align="center" prop="identify" />
            <el-table-column label="FW版本" align="center" prop="bugVersion" />
            <el-table-column label="问题类别" align="center" prop="problemType" />
            <el-table-column fixed label="不良现象描述" width="200" align="left" prop="bugDescriptions" />
            <el-table-column label="提出时间" align="center" prop="bugCreateTime">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.bugCreateTime, '{y}-{m}-{d}') }}</span>
                </template>
            </el-table-column>
            <el-table-column fixed label="提交人" width="125" align="center" prop="bugCreateUser" />
            <el-table-column label="严重程度" align="center" prop="level">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.problem_level" :value="scope.row.level" />
                </template>
            </el-table-column>
            <el-table-column label="设备型号" align="center" prop="modelCode" />
            <el-table-column label="不良率" align="center" prop="badPersentage" />
            <!-- <el-table-column label="bug标题" width="200" :show-overflow-tooltip="true" align="left" prop="bugTitle" /> -->
            <!-- <el-table-column label="bug版本" align="center" prop="bugVersion" /> -->
            <el-table-column fixed  label="原因分析" width="200" align="center" prop="bugAnalysis" />
            <el-table-column fixed label="改善对策" width="200" align="center" prop="bugAnswer" />
            <el-table-column fixed label="责任人" align="center" prop="respon" />
            <el-table-column label="改善时间" align="center" prop="recoverTime">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.recoverTime, '{y}-{m}-{d}') }}</span>
                </template>
            </el-table-column>
            <el-table-column label="close Fw版本" align="center" prop="closeVersion" />
            <el-table-column label="bug状态" align="center" prop="bugStatus">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.bugs_status" :value="scope.row.bugStatus" />
                </template>
            </el-table-column>
            <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" v-show="scope.row.status != 20" icon="el-icon-edit"
                        @click="handleUpdate(scope.row)" v-hasPermi="['business:project:update']">修改</el-button>
                    <el-button size="mini" type="text" v-show="scope.row.status != 20" icon="el-icon-delete"
                        @click="handleDelete(scope.row)" v-hasPermi="['business:project:delete']">删除</el-button>
                    <el-button size="mini" type="warning" @click="closeProject(scope.row)" v-show="scope.row.status != 20"
                        v-hasPermi="['business:project:close']">关闭</el-button>
                </template>
            </el-table-column> -->
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />

    </div>
</template>

<script>
import { projectBugsList } from "@/api/business/bugs"
export default {
    name: 'BugsList',
    dicts: ['bugs_status', 'problem_level'],
    data() {
        return {
            projectBugList: [],
            // 遮罩层
            loading: false,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                bugCode: null,
                custom: null,
                model: null,
                chipGroup: null,
                lcmOc: null,
                adBoard: null,
                powerSupply: null,
                armBoard: null,
                currentBoard: null,
                projectNo: null,
                identify: null,
                level: null,
                modelCode: null,
                badPersentage: null,
                bugStatus: null,
                powerSuppleId: null,
                lcmOcId: null,
                respon: null,
                bugCreateUser:null,
            },
        };
    },
    computed: {
    },
    watch: {
    },
    created() {
        this.getList();
    },
    methods: {
        //设置行数据样式
        tableRowClassName({ row, rowIndex }) {
            if (row.bugStatus === "40") {
                return 'close-row';
            } else {
                return '';
            }
        },
        getList() {
            this.loading = true;
            // console.log(this.queryParams);
            projectBugsList(this.queryParams).then(response => {
                this.projectBugList = response.rows;
                this.total = response.total;
                this.loading = false;
            })
        },
        onInputChange0(event) {
            this.queryParams.powerSupply = event
            this.getList()
        },
        onInputChange1(event) {
            // console.log(event)
            this.queryParams.custom = event
            this.getList()
        },
        onInputChange2(event) {

            this.queryParams.model = event
            this.getList()
        },
        onInputChange3(event) {
            this.queryParams.chipGroup = event
            this.getList()
        },
        onInputChange4(event) {
            this.queryParams.adBoard = event
            this.getList()
        },
        onInputChange5(event) {
            this.queryParams.lcmOc = event
            this.getList()
        },
        onInputChange6(event) {
            this.queryParams.armBoard = event
            this.getList()
        },
        onInputChange7(event) {
            this.queryParams.currentBoard = event
            this.getList()
        },
        onInputChange8(event) {
            this.queryParams.projectNo = event
            this.getList()
        },
        onInputChange9(event) {
            this.queryParams.other = event
            this.getList()
        },
        inputOnchange1(event) {
            this.queryParams.bugCode = event
            this.getList()
        },
        inputOnchange2(event) {
            this.queryParams.identify = event
            this.getList()
        },
        inputOnchange3(event) {
            this.queryParams.level = event
            this.getList()
        },
        inputOnchange4(event) {
            this.queryParams.modelCode = event
            this.getList()
        },
        inputOnchange5(event) {
            this.queryParams.badPersentage = event
            this.getList()
        },
        inputOnchange6(event) {
            this.queryParams.powerSuppleId = event
            this.getList()
        },
        inputOnchange7(event) {
            this.queryParams.lcmOcId = event
            this.getList()
        },
        inputOnchange8(event){
            this.queryParams.respon = event
            this.getList()
        },
        inputOnchange9(event){
            this.queryParams.createUserName = event
            this.getList()
        },
        inputOnchange9(event) {
            this.queryParams.createUserName = event
            this.getList()
        },
        onInputChange10(event) {
            this.queryParams.bugStatus = event
            this.getList()
        },
        onInputChange11(event) {
            this.queryParams.createTime = event
            this.getList()
        },
        selectChange(event) {
            this.queryParams.bugStatus = event
            this.getList()
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download('business/bugs/export', {
                ...this.queryParams
            }, `全部bugs库_${new Date().getTime()}.xlsx`);
        },
        /** 导出按钮操作 */
        handleExportTwo() {
            this.download('business/bugs/exportTwo', {
                ...this.queryParams
            }, `bugs库_${new Date().getTime()}.xlsx`);
        },
    },
};
</script>

<style lang="scss" scoped>
.labelword ::v-deep .el-form-item__label {
    white-space: pre-line !important;
    line-height: 15px !important;
}

.el-table .close-row {
    background: #e0e0e0;
}
</style>
